package com.example.a79273.shandianban.model;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

import org.json.JSONException;
import org.json.JSONObject;

import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by lenovo on 2016/8/29.
 */
public class YouHuoBean {
    @Override
    public String toString() {
        return "YouHuoBean{" +
                "error_code=" + error_code +
                ", error_msg='" + error_msg + '\'' +
                ", total=" + total +
                ", data=" + data +
                '}';
    }

    /**
     * error_code : 0
     * error_msg : 获取数据成功
     * total : 4
     * data : {"list":[{"proid":"214001664286","name":"简约休闲长版薄外套","price":126,"sales":0,"style":"Stripelife","type":"2","collar":"上装","url":"/Upload/Product/214001664286/37e1408925_mobile.jpg","href":"api/Mall/ProductsDetails/214001664286","mark":"康梓","cateid":"83104c90-6691-4f7e-8373-b54bda479060","catename":"上装"},{"proid":"214001664345","name":"细纹圆领套头衫","price":110,"sales":0,"style":"Stripelife","type":"2","collar":"上装","url":"/Upload/Product/214001664345/37e1408a08_mobile.jpg","href":"api/Mall/ProductsDetails/214001664345","mark":"康梓","cateid":"83104c90-6691-4f7e-8373-b54bda479060","catename":"上装"},{"proid":"214001664782","name":"简约条纹V领单扣外套","price":186,"sales":0,"style":"Stripelife","type":"2","collar":"上装","url":"/Upload/Product/214001664782/37e14fcd14_mobile.jpg","href":"api/Mall/ProductsDetails/214001664782","mark":"康梓","cateid":"83104c90-6691-4f7e-8373-b54bda479060","catename":"上装"},{"proid":"241000744112","name":"麻绳编织长款针织毛衣","price":118,"sales":0,"style":"纯粹","type":"2","collar":"上装","url":"/Upload/Product/241000744112/381cd2ca3c_mobile.jpg","href":"api/Mall/ProductsDetails/241000744112","mark":"Andy","cateid":"83104c90-6691-4f7e-8373-b54bda479060","catename":"上装"}],"page_info":{"page_count":4,"page":1,"page_size":4}}
     */

    private int error_code;
    private String error_msg;
    private int total;
    /**
     * list : [{"proid":"214001664286","name":"简约休闲长版薄外套","price":126,"sales":0,"style":"Stripelife","type":"2","collar":"上装","url":"/Upload/Product/214001664286/37e1408925_mobile.jpg","href":"api/Mall/ProductsDetails/214001664286","mark":"康梓","cateid":"83104c90-6691-4f7e-8373-b54bda479060","catename":"上装"},{"proid":"214001664345","name":"细纹圆领套头衫","price":110,"sales":0,"style":"Stripelife","type":"2","collar":"上装","url":"/Upload/Product/214001664345/37e1408a08_mobile.jpg","href":"api/Mall/ProductsDetails/214001664345","mark":"康梓","cateid":"83104c90-6691-4f7e-8373-b54bda479060","catename":"上装"},{"proid":"214001664782","name":"简约条纹V领单扣外套","price":186,"sales":0,"style":"Stripelife","type":"2","collar":"上装","url":"/Upload/Product/214001664782/37e14fcd14_mobile.jpg","href":"api/Mall/ProductsDetails/214001664782","mark":"康梓","cateid":"83104c90-6691-4f7e-8373-b54bda479060","catename":"上装"},{"proid":"241000744112","name":"麻绳编织长款针织毛衣","price":118,"sales":0,"style":"纯粹","type":"2","collar":"上装","url":"/Upload/Product/241000744112/381cd2ca3c_mobile.jpg","href":"api/Mall/ProductsDetails/241000744112","mark":"Andy","cateid":"83104c90-6691-4f7e-8373-b54bda479060","catename":"上装"}]
     * page_info : {"page_count":4,"page":1,"page_size":4}
     */

    private DataBean data;

    public static YouHuoBean objectFromData(String str) {

        return new Gson().fromJson(str, YouHuoBean.class);
    }

    public static YouHuoBean objectFromData(String str, String key) {

        try {
            JSONObject jsonObject = new JSONObject(str);

            return new Gson().fromJson(jsonObject.getString(str), YouHuoBean.class);
        } catch (JSONException e) {
            e.printStackTrace();
        }

        return null;
    }

    public static List<YouHuoBean> arrayYouHuoBeanFromData(String str) {

        Type listType = new TypeToken<ArrayList<YouHuoBean>>() {
        }.getType();

        return new Gson().fromJson(str, listType);
    }

    public static List<YouHuoBean> arrayYouHuoBeanFromData(String str, String key) {

        try {
            JSONObject jsonObject = new JSONObject(str);
            Type listType = new TypeToken<ArrayList<YouHuoBean>>() {
            }.getType();

            return new Gson().fromJson(jsonObject.getString(str), listType);

        } catch (JSONException e) {
            e.printStackTrace();
        }

        return new ArrayList();


    }

    public int getError_code() {
        return error_code;
    }

    public void setError_code(int error_code) {
        this.error_code = error_code;
    }

    public String getError_msg() {
        return error_msg;
    }

    public void setError_msg(String error_msg) {
        this.error_msg = error_msg;
    }

    public int getTotal() {
        return total;
    }

    public void setTotal(int total) {
        this.total = total;
    }

    public DataBean getData() {
        return data;
    }

    public void setData(DataBean data) {
        this.data = data;
    }

    public static class DataBean {
        /**
         * page_count : 4
         * page : 1
         * page_size : 4
         */

        private PageInfoBean page_info;
        /**
         * proid : 214001664286
         * name : 简约休闲长版薄外套
         * price : 126.0
         * sales : 0
         * style : Stripelife
         * type : 2
         * collar : 上装
         * url : /Upload/Product/214001664286/37e1408925_mobile.jpg
         * href : api/Mall/ProductsDetails/214001664286
         * mark : 康梓
         * cateid : 83104c90-6691-4f7e-8373-b54bda479060
         * catename : 上装
         */

        private List<ListBean> list;

        public static DataBean objectFromData(String str) {

            return new Gson().fromJson(str, DataBean.class);
        }

        public static DataBean objectFromData(String str, String key) {

            try {
                JSONObject jsonObject = new JSONObject(str);

                return new Gson().fromJson(jsonObject.getString(str), DataBean.class);
            } catch (JSONException e) {
                e.printStackTrace();
            }

            return null;
        }

        public static List<DataBean> arrayDataBeanFromData(String str) {

            Type listType = new TypeToken<ArrayList<DataBean>>() {
            }.getType();

            return new Gson().fromJson(str, listType);
        }

        public static List<DataBean> arrayDataBeanFromData(String str, String key) {

            try {
                JSONObject jsonObject = new JSONObject(str);
                Type listType = new TypeToken<ArrayList<DataBean>>() {
                }.getType();

                return new Gson().fromJson(jsonObject.getString(str), listType);

            } catch (JSONException e) {
                e.printStackTrace();
            }

            return new ArrayList();


        }

        public PageInfoBean getPage_info() {
            return page_info;
        }

        public void setPage_info(PageInfoBean page_info) {
            this.page_info = page_info;
        }

        public List<ListBean> getList() {
            return list;
        }

        public void setList(List<ListBean> list) {
            this.list = list;
        }

        public static class PageInfoBean {
            private int page_count;
            private int page;
            private int page_size;

            public static PageInfoBean objectFromData(String str) {

                return new Gson().fromJson(str, PageInfoBean.class);
            }

            public static PageInfoBean objectFromData(String str, String key) {

                try {
                    JSONObject jsonObject = new JSONObject(str);

                    return new Gson().fromJson(jsonObject.getString(str), PageInfoBean.class);
                } catch (JSONException e) {
                    e.printStackTrace();
                }

                return null;
            }

            public static List<PageInfoBean> arrayPageInfoBeanFromData(String str) {

                Type listType = new TypeToken<ArrayList<PageInfoBean>>() {
                }.getType();

                return new Gson().fromJson(str, listType);
            }

            public static List<PageInfoBean> arrayPageInfoBeanFromData(String str, String key) {

                try {
                    JSONObject jsonObject = new JSONObject(str);
                    Type listType = new TypeToken<ArrayList<PageInfoBean>>() {
                    }.getType();

                    return new Gson().fromJson(jsonObject.getString(str), listType);

                } catch (JSONException e) {
                    e.printStackTrace();
                }

                return new ArrayList();


            }

            public int getPage_count() {
                return page_count;
            }

            public void setPage_count(int page_count) {
                this.page_count = page_count;
            }

            public int getPage() {
                return page;
            }

            public void setPage(int page) {
                this.page = page;
            }

            public int getPage_size() {
                return page_size;
            }

            public void setPage_size(int page_size) {
                this.page_size = page_size;
            }
        }

        public static class ListBean {
            @Override
            public String toString() {
                return "ListBean{" +
                        "proid='" + proid + '\'' +
                        ", name='" + name + '\'' +
                        ", price=" + price +
                        ", sales=" + sales +
                        ", style='" + style + '\'' +
                        ", type='" + type + '\'' +
                        ", collar='" + collar + '\'' +
                        ", url='" + url + '\'' +
                        ", href='" + href + '\'' +
                        ", mark='" + mark + '\'' +
                        ", cateid='" + cateid + '\'' +
                        ", catename='" + catename + '\'' +
                        '}';
            }

            private String proid;
            private String name;
            private double price;
            private int sales;
            private String style;
            private String type;
            private String collar;
            private String url;
            private String href;
            private String mark;
            private String cateid;
            private String catename;

            public static ListBean objectFromData(String str) {

                return new Gson().fromJson(str, ListBean.class);
            }

            public static ListBean objectFromData(String str, String key) {

                try {
                    JSONObject jsonObject = new JSONObject(str);

                    return new Gson().fromJson(jsonObject.getString(str), ListBean.class);
                } catch (JSONException e) {
                    e.printStackTrace();
                }

                return null;
            }

            public static List<ListBean> arrayListBeanFromData(String str) {

                Type listType = new TypeToken<ArrayList<ListBean>>() {
                }.getType();

                return new Gson().fromJson(str, listType);
            }

            public static List<ListBean> arrayListBeanFromData(String str, String key) {

                try {
                    JSONObject jsonObject = new JSONObject(str);
                    Type listType = new TypeToken<ArrayList<ListBean>>() {
                    }.getType();

                    return new Gson().fromJson(jsonObject.getString(str), listType);

                } catch (JSONException e) {
                    e.printStackTrace();
                }

                return new ArrayList();


            }

            public String getProid() {
                return proid;
            }

            public void setProid(String proid) {
                this.proid = proid;
            }

            public String getName() {
                return name;
            }

            public void setName(String name) {
                this.name = name;
            }

            public double getPrice() {
                return price;
            }

            public void setPrice(double price) {
                this.price = price;
            }

            public int getSales() {
                return sales;
            }

            public void setSales(int sales) {
                this.sales = sales;
            }

            public String getStyle() {
                return style;
            }

            public void setStyle(String style) {
                this.style = style;
            }

            public String getType() {
                return type;
            }

            public void setType(String type) {
                this.type = type;
            }

            public String getCollar() {
                return collar;
            }

            public void setCollar(String collar) {
                this.collar = collar;
            }

            public String getUrl() {
                return url;
            }

            public void setUrl(String url) {
                this.url = url;
            }

            public String getHref() {
                return href;
            }

            public void setHref(String href) {
                this.href = href;
            }

            public String getMark() {
                return mark;
            }

            public void setMark(String mark) {
                this.mark = mark;
            }

            public String getCateid() {
                return cateid;
            }

            public void setCateid(String cateid) {
                this.cateid = cateid;
            }

            public String getCatename() {
                return catename;
            }

            public void setCatename(String catename) {
                this.catename = catename;
            }
        }
    }
}
